In this tutorial, we will learn how to get the current date using Vue 3 and the new Date()
object to dynamically retrieve the current date.
How to Get Current Date in Vue 3?
In the example below, we provide code to get the current date in Vue 3. Check it out now and use it in your project. You can also try editing or customizing it to suit your preferences.
Vue 3 Get Current Date
<script type="module">
const {createApp, ref,onMounted} = Vue;
createApp({
setup() {
const currentDate = ref('');
onMounted(() => {
getCurrentDate();
});
function getCurrentDate() {
const date = new Date();
currentDate.value = date.toDateString();
}
return {
currentDate
};
}
}).mount("#app");
</script>